package com.baox.agridata.synchronous.controller;


import com.alibaba.fastjson.JSON;
import com.baox.agridata.synchronous.service.business.AsyncLogOperationService;
import com.baox.agridata.synchronous.service.business.SupplementDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/business")
@CrossOrigin
public class BusinessController {


    @Autowired
    private SupplementDataService supplementAnimalA;


    /**
     * 补充动物A
     *
     * @param factoryCode
     * @return
     */
    @GetMapping("/supplementAnimalA")
    public String supplementAnimalA(String factoryCode) {
        Map map = supplementAnimalA.supplementAnimalA(factoryCode);
        return JSON.toJSONString(map);
    }

    /**
     * 补充动物B
     *
     * @param factoryCode
     * @return
     */
    @GetMapping("/supplementAnimalB")
    public String supplementAnimalB(String factoryCode) {
        Map map = supplementAnimalA.supplementAnimalB(factoryCode);
        return JSON.toJSONString(map);
    }

    /**
     * 补充产品A
     *
     * @param factoryCode
     * @return
     */
    @GetMapping("/supplementProductA")
    public String supplementProductA(String factoryCode) {
        Map map = supplementAnimalA.supplementProductA(factoryCode);
        return JSON.toJSONString(map);
    }


    /**
     * 补充产品B
     *
     * @param factoryCode
     * @return
     */
    @GetMapping("/supplementProductB")
    public String supplementProductB(String factoryCode) {
        Map map = supplementAnimalA.supplementProductB(factoryCode);
        return JSON.toJSONString(map);
    }

    /**
     * 作废检疫证
     *
     * @param type        1.动物A 2.动物B 3.产品A  4.产品B
     * @param factoryCode 检疫证号
     */
    @GetMapping("/cancelCertificate")
    public String cancelCertificate(Integer type, String factoryCode) {
        Map map = supplementAnimalA.cancelCertificate(type, factoryCode);
        return JSON.toJSONString(map);
    }

}
